Product Information: Multitasking Toolkit V2.5 for Turbo Pascal --------------------------------------------------------------- 1. Contents of this file This file contains the following information about the Multitasking Toolkit (CPMULTI). 1. Contents of this file 2. Overview 3. Summary of features 4. List of routines available 5. The demo programs (executables and source) 6. Questions and answers 7. ORDERING INFORMATION Please note: This demo diskette may be freely copied and distributed in electronic form (including uploading to "bulletin boards" or other online services) so long as it is not altered in any way. In addition, this informational text file may be copied and distributed in printed form so long as it is not altered. 2. Overview The Multitasking Toolkit has been around in several versions since 1988. It is used by software houses, major accounts and universities all over the world. There are installations today in Germany, the USA, Canada, Austria, Switzerland, Hungary, the CSFR, Brazil and the Netherlands. The Multitasking Toolkit consists of several Turbo Pascal units which provide the programmer with everything needed to execute any number of Pascal procedures in parallel (in a multi-threaded application). The available computing power is divided among all competing tasks by a dynamic preemptive scheduler. By assigning a task to one of nine priority levels, the programmer may prioritize the processes according to their role in the application. The Multitasking Toolkit allows the application to change the minimum size of a time-slice (>= 5 milliseconds) and also the range in which the scheduler may dynamically adjust timeslices. In this way, high-priority tasks can be made to react very quickly to external events, so that the toolkit is suited very well to developing device control and data communications applications. Any multitasking application needs a way to synchronize access to resources and to exchange data between processes. The Multitasking Toolkit offers semaphores, resources, message-passing, pipes and finally, events and timers. A basic set of serial comm functions which interface to the multitasking toolkit and a character oriented print spooler are provided and smoothly integrated into the package. The spooler is fully compatible with the PRINTER unit and may therefore be used as a plug-in replacement. The Multitasking Toolkit is aware of the "DOS reentrance" problem and automatically synchronizes access to DOS. Therefore tasks may concurrently execute DOS functions without any precautions being taken by the programmer. In addition, one external program (such as COMMAND.COM) may be executed in parallel to the Turbo Pascal application. This enables the programmer to easily develop a multitasking background application which is able to control the foreground task if necessary (inhibit keyboard I/O, stuff keys into the keyboard buffer, suspend the foreground process, etc.). Tasks may be kept waiting for a hot-key combination to be pressed (like a pseudo-TSR). The hot-key task will be activated even if the hot-key is pressed in the foreground application. A separate unit is included in the Multitasking Toolkit to transparently synchronize access to the Turbo Pascal heap. This makes writing multi- tasking applications very easy, especially when using the object-oriented language enhancements, because there are no special precautions needed in order to prevent heap corruption. 3. Summary of features General: - Runs on any PC, XT, AT, PS/2 and 100% compatible systems - Compatible with DOS 2.11 and above, as well as DR DOS 3.41 and above - Supports Turbo Pascal 5.0, 5.5, 6.0, 7.0 and Borland Pascal 7.0 (real mode) - No runtime-license payments - Full source code available - Printed documentation - Very robust implementation Kernel: - Unlimited number of tasks - 9 priority levels - Priorities may be changed at runtime - Compatible to MS-Windows DOS-box - Code sharing - Preemptive scheduler - Programmable timeslice (>= 5 ms) - Dynamic adjustment of timeslices - Time slicing may be switched off for full application control - Safe to do concurrent DOS I/O (no task switch while any task is executing OS code) - Optional "exclusive mode" on a per-task basis (task running in this mode is never preempted) Task Synchronization and IPC: - Semaphores - Message-passing - "Named pipes" (Turbo Pascal TEXT-file driver) - Resources - Programmable timer - Easy-to-use event handling (continued next page) What else? - Character-oriented print spooler (LST-device) - Interrupt-driven serial I/O-handling - Pipe interface to serial I/O-unit (read/write to the port via Read/Write, etc.) - Extended keycodes (character, scan-code, shift-status) - Full keyboard control - Run one external DOS-program as a sub-task - Hot-key activation of tasks 4. List of routines available This is a list of all the procedures and functions in the API of the Multitasking Toolkit: Task management routines procedure ChangePri(Task:TaskNoType; Pri:Priority); function CreateTask(TaskPointer:TaskType; UserData:Pointer; procedure Kill(Task:TaskNoType); function ReadySuspended(Task:TaskNoType) : Boolean; procedure SetPri(Pri:Priority); procedure Sleep(Ticks:LongInt); procedure SpeedUp(Factor:Word); function Suspend(Task:TaskNoType) : Boolean; procedure Terminate; procedure DoShutdown; procedure TimeSlice(Slice, DynQ:Byte); procedure Sched; Misc. synchronization routines procedure BindCPU; function EnterExclusive : Boolean; procedure LeaveExclusive; procedure ReleaseCPU; Semaphores function CreateSem(var SemPtr:Pointer) : SemReturn; function RemoveSem(var SemPtr:Pointer) : SemReturn; function RemoveSemKill(var SemPtr:Pointer) : SemReturn; procedure SemClear(SemPtr:Pointer); procedure SemClearWait(SemPtr:Pointer); function SemCut(SemPtr:Pointer;Task:TaskNoType) : Boolean; procedure SemDiag(SemPtr:Pointer; Txt:String); function SemGetSignals(SemPtr:Pointer) : Word; procedure SemPaste(SemPtr:Pointer; Task:TaskNoType); procedure SemSet(SemPtr:Pointer; Count:Word); procedure SemSignal(SemPtr:Pointer); function SemSoWaiting(SemPtr:Pointer) : Boolean; function SemWaiting(SemPtr:Pointer) : Boolean; procedure SemWait(SemPtr:Pointer); Inter-process communication function Receive(FromTask:TaskNoType; MsgBuff:Pointer; WaitFlag:WaitFlagType) : TaskReturn; function ReceivedFrom : TaskNoType; function Send(ToTask:TaskNoType; Msg:Pointer; MsgSize:Word; WaitFlag:WaitFlagType) : TaskReturn; Events function MemoryEventWait(MemPtr:Pointer) : Boolean; function PortEventWait(EPortNo:Word; var ENewValue:Byte) : Boolean; Timers function CancelTimer(MemPtr:Pointer) : Boolean; function CancelWatchdog(TWatchdog:WatchdogType) : Boolean; function QueueTimer(MemPtr:Pointer; Counter:Word) : Boolean; function QueueWatchdog(TWatchdog:WatchdogType; Information and debugging function GetPID : TaskNoType; function GetPri : Priority; function GetTaskState(Task:TaskNoType) : TaskStatus; function GetTimBusy : BPtr; procedure DumpTaskTable; function Seconds(Sec:Word) : LongInt; Resources function GrantRsc(RscPtr:Pointer) : RscReturn; function ReleaseRsc(RscPtr:Pointer) : RscReturn; function CreateRsc(var RscPtr:Pointer) : RscReturn; function RemoveRsc(RscPtr:Pointer) : RscReturn; function RemoveRscKill(RscPtr:Pointer) : RscReturn; function RequestRsc(RscPtr:Pointer, WaitFlag:WaitFlagType) : RscReturn; Pipes function AssignPipe(var PT:Text; PName:PipeNameType; PSize:Word; RequestSize:Byte; AlwaysBlock:WaitFlagType) : Boolean; function ExistPipe(PName:PipeNameType) : Boolean; function ReadPipeDirect(var PT:Text; var Buf; Count:Word) : Boolean; function WritePipeDirect(var PT:Text; var Buf; Count:Word) : Boolean; Print spooler procedure CancelPrint; function PrintBufferAvail : Word; function PrintBufferFilled : Word; function PrinterReady : Boolean; procedure RestartSpooler(Size:Word); function SpoolerBusy : Boolean; Serial communications function AuxSendTimeout : Boolean; procedure CloseAux(Reading:TaskNoType); procedure OpenAux(ComPort:ComType; BaudRate:BaudType; Parity:ParityType; Bits:DataBitsType; Stop:StopBitsType; BufSize:Word); DOS tasks, popups, and keyboard handling procedure CallDos(Path, CmdLin:String); function DeregisterPopUp(Handle:Byte) : Boolean; procedure DisablePopUps; procedure EnablePopUps; function GetKey : LongInt; function LongIntToHex(Value:LongInt) : LongHex; procedure KbdAppend(Task:TaskNoType); function KbdDisable(Task:TaskNoType) : Boolean; procedure StateToTurbo; 5. The demo programs All of these demo programs can be found on the demo diskette both in executable form and with full Pascal source code. BEEPER.PAS This program demonstrates some of the most basic features of the CPMulti kernel, including semaphores, code sharing, and priority changing. CALLDOS.PAS This program demonstrates the capabilities of MTPopup by executing COMMAND.COM as a task, giving a DOS shell to the user. Pressing F10 will show the task status window. FINDER.PAS This program searches multiple disks for occurrences of the specified filenames. For each search request, a separate process is started. GLASSTTY.PAS This is a bare-bones terminal emulator which illustrates the use of the CommPipe unit. KBTEST.PAS This demo program shows the keyboard-handling capabilities of the MTPopup unit. For each key the user presses, all available information is displayed. Pressing Escape will end the program. LSTTEST.PAS This demo program uses the MTPrint unit to implement a simple print spooler. MTEST.PAS This illustrates the most basic use of the message-passing functions in the CPMulti kernel. PHILO.PAS This is a solution for the classic "Dining Philosophers" problem, which deals with resource contention. PRO_CON.PAS This illustrates keyboard handling (XON, XOFF) as an instance of the producer-consumer problem. QUETEST.PAS This demonstrates the Queue unit; it allows the user to enter a list of strings into a queue and then delete them selectively. RSCTEST.PAS This program shows the basic use of the resource functions in the CPMulti kernel. SPEEDUP.PAS This program is an illustration of the SpeedUp function. TASKWIN.PAS This program demonstrates simple code sharing between concurrent tasks. 6. Questions and Answers Why program under DOS anyway, as opposed to a multitasking operating system? For one thing, the operating system overhead is less. Some vendors report that the DOS version of a program can run up to ten times faster than the Windows version on the same machine. In many applications, speed is critically important. For another thing, programming in DOS does not require dealing with a complex API such as that of Windows. Programmers who are unfamiliar with an event-driven message-passing paradigm often find it difficult to program for Windows or OS/2. Also, it should be noted that Windows 3.1 is a cooperative (not pre- emptive) multitasking environment. This disadvantage does not exist with the toolkit. To be fair, Windows NT and OS/2 do not have this problem either; but they are still less common than Windows. What versions of Turbo Pascal are supported? Versions 5.0, 5.5, 6.0, and 7.0. What versions of DOS are supported? PC DOS or MS DOS, versions 2.1 or later; DR DOS, versions 3.41 or later. The toolkit has not been tested with Novell DOS 7; it is conceivable that there might be conflicts with the intrinsic multi- tasking features of the new operating system. What are the minimum hardware requirements? CPMULTI should run on a machine with the 80286 processor or any later chip in the family (386, 486, Pentium). There are no specific minimum memory requirements. Is there support for object-oriented programming (OOP)? CPMULTI applications may use OOP freely, of course. However, there is currently no object-oriented version of the application programming interface; e.g., there is no "Semaphore" object with its own methods, constructor, and destructor. Does the toolkit support Turbo Vision? Programs using CPMULTI may make free use of Turbo Vision (provided the GrabHeap unit has been included); but there is no explicit interaction between TV and CPMULTI. Are there royalties required for use of the units? No! The toolkit may be used royalty-free, provided, of course, that the individual units comprising CPMULTI are not distributed as units or as source, but only as part of the linked .EXE file. Does the toolkit support protected mode (DPMI) programming under Borland Pascal 7.0? Protected mode is not yet supported. Early experiments have shown, however that it can be done with major changes in the assembly language modules of the kernel. Possible releases of the toolkit may contain protecte mode support. Is the toolkit useful in Windows programming? There is no support for Microsoft Windows nor any interaction with it. However, applications using CPMULTI will run in a DOS window just as they will run under DOS. What about technical support? In the past, this has been provided by the author, who may continue to do so at his own discretion. In no event will the distributor be responsible for technical support. How can I order CPMULTI? See the final section below, ORDERING INFORMATION. How can I contact the author? The author may be reached at the following address: Christian Philipps Software-Technik Duesseldorfer Str. 316 D-47447 Moers Germany Phone: 0049-2841-35932 Internet: chrispi@sequent.com CompuServe: [100012,1227] 7. ORDERING INFORMATION CPMULTI may be ordered from the distributor, Hypermetrics, at the following address: Hypermetrics PO Box 9700 Suite 363 Austin, TX 78766-9700 Phone: (512) 244-7833 (voice mail, fax) Internet: hal9000@netcom.com CompuServe: [71540,3514] Pricing as of January 1, 1994 is as follows: $ 99 for object code only; $299 for the version with full source code. Add $5 for shipping and handling. Residents of Texas should also add 8% for state sales tax. Payment may be made by check or money order. Purchase orders will be accepted from corporate or government entities. Note that credit cards cannot be accepted. The standard medium is a 3.5" diskette; users requiring 5.25" diskettes should request that size. Call for site license information or upgrades for registered users of the older shareware version.